﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace AMing.Mvc4.Web
{
    public class HostNameView
    {
        /// <summary>
        /// 初始化HostnameHelper
        /// </summary>
        /// <param name="request"></param>
        public HostNameView(Func<string, ViewResult> view)
        {
            this.JumpViewResult = view;
        }

        /// <summary>
        /// 提供用于响应对 ASP.NET MVC 网站所进行的 HTTP 请求的方法。
        /// </summary>
        private Func<string, ViewResult> JumpViewResult { get; set; }

        /// <summary>
        /// 主机名跳转
        /// </summary>
        /// <param name="defaultActionResult"></param>
        /// <param name="hostnames"></param>
        /// <returns></returns>
        public ViewResult View(HostNameEnum hostnameEnum, string viewName)
        {
            string folder = "";

            if (HostNameData.ViewList.ContainsKey(hostnameEnum))
            {
                folder = HostNameData.ViewList[hostnameEnum];
            }

            return JumpViewResult(string.Format("{0}{1}.cshtml", folder, viewName));
        }
    }
}
